package com.gxa.controller.resume;

import com.gxa.common.R.ResponseData;
import com.gxa.pojo.Jianli;
import com.gxa.service.resume.MianShiService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Api(value ="人才库储备",tags ="人才库储备API" )
@Controller
@RequestMapping("/mianShi")
public class MianShiController {
    @Autowired
    private MianShiService mianShiService;
    /*
    登录
     */
    @ResponseBody
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    @ApiOperation(value = "登录",notes = "登录人才库",httpMethod = "get", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "电话号码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData login(@RequestParam String phone,
                              @RequestParam String password){
        return mianShiService.login(phone,password);
    }
    /*
    注册
     */
    @ResponseBody
    @RequestMapping(value = "/register",method = RequestMethod.POST)
    @ApiOperation(value = "注册",notes = "登录人才库",httpMethod = "post", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "电话号码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "sex", value = "性别 1为男 0为女", required = true, dataType = "int"),
            @ApiImplicitParam(name = "educated", value = "学历", required = true, dataType = "String"),
            @ApiImplicitParam(name = "name", value = "姓名", required = true, dataType = "String"),
            @ApiImplicitParam(name = "height", value = "身高", required = true, dataType = "String")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData register(@RequestParam String phone,
                                 @RequestParam int sex,
                                 @RequestParam String educated,
                                 @RequestParam String name,
                                 @RequestParam String password,
                                 @RequestParam String height){

        return mianShiService.register(phone,password,name,sex,educated,height);
    }
    /*
    修改密码
     */
    @ResponseBody
    @RequestMapping(value = "/updatePassword",method = RequestMethod.POST)
    @ApiOperation(value = "修改密码",notes = "修改密码",httpMethod = "post", response = ResponseData.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "电话号码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "password", value = "密码", required = true, dataType = "String"),
            @ApiImplicitParam(name = "newPassword", value = "新密码密码", required = true, dataType = "String"),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData updatePassword(@RequestParam String phone,
                                 @RequestParam String password,
                                 @RequestParam String newPassword
                                 ){
        return mianShiService.updatePassword(phone,password,newPassword);
    }
    /*
    更新简历信息
     */
    @ResponseBody
    @RequestMapping(value = "/updateJianLi",method = RequestMethod.POST)
    @ApiOperation(value = "更新简历信息",notes = "更新简历信息",httpMethod = "post", response = ResponseData.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public ResponseData updateJianLi(@RequestBody Jianli jianli){
        return mianShiService.updateJianLi(jianli);
    }
}
